package org.cyhz.standardize.service;

import java.sql.SQLException;

import org.cyhz.util.Log;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

@Service("mainServiceFactory")
public class MainServiceFactory implements ApplicationContextAware {

	private ApplicationContext applicationContext;

	@Value("${serviceName}")
	private String serviceName;

	public void start() throws SQLException {

		Log.info("service is :" + serviceName);
		BrandSeriesStandardizeService brandSeriesStandardizeService = (BrandSeriesStandardizeService) applicationContext
				.getBean(serviceName);
		Log.info("service is :"
				+ brandSeriesStandardizeService.getClass().toString());
		brandSeriesStandardizeService.standardize();
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.applicationContext = applicationContext;
	}

}
